package com.metis.document.parse.dialog.entity;

import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;

import com.metis.document.parse.dialog.constant.FileStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.FieldNameConstants;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

@FieldNameConstants
@Getter
@Setter
@Entity
@Builder
@Table(name = "parse_task", indexes = {
        @Index(name = "idx_checksum", columnList = TaskPO.Fields.checksum, unique = false)
})
@DynamicUpdate
@DynamicInsert
@NoArgsConstructor
@AllArgsConstructor
public class TaskPO {
    @Id
    @GenericGenerator(name = "CustomIdGenerator", strategy = "assigned")
    @GeneratedValue(generator = "CustomIdGenerator")
    @Column(name = Fields.id, nullable = false)
    private Long id;
    //文件名称
    @Column(name = Fields.filename, nullable = false)
    private String filename;
    //文件大小
    @Column(name = Fields.filesize, nullable = false)
    private Long filesize;
    //文件路径
    @Column(name = Fields.filepath, nullable = false, columnDefinition = "MediumText")
    private String filepath;
    //文件解析结果
    @Column(name = Fields.result_filepath, nullable = false, columnDefinition = "MediumText")
    private String result_filepath;
    //文件状态
    @Column(name = Fields.status, nullable = false)
    @Enumerated(value = EnumType.STRING)
    private FileStatus status;
    //文件校验码
    @Column(name = Fields.checksum, nullable = true)
    private String checksum;
    //文件解析开始时间
    @Column(name = Fields.start_time, nullable = true)
    private LocalDateTime start_time;
    //文件解析结束时间
    @Column(name = Fields.end_time, nullable = true)
    private LocalDateTime end_time;
    //失败原因,MediumText
    @Column(name = Fields.fail_reason, nullable = true, columnDefinition = "MediumText")
    private String fail_reason;


}
